//
//  Backgroundimageview.m
//  MusicPlayer
//
//  Created by HUA on 15/6/26.
//  Copyright (c) 2015年 HUA. All rights reserved.
//

#import "Backgroundimageview.h"

@implementation Backgroundimageview

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (id)initWithFrame:(CGRect)frame image:(NSString *)image
{
   self =  [super initWithFrame:frame];
    if (self)
    {
        
        //IOS8新特性  模糊效果
        //创建一个imageview 大小是整个屏幕这么大
        self.frame = [UIScreen mainScreen].bounds;
        self.userInteractionEnabled = YES;
        //确定我们的背景图
        self.image = [UIImage imageNamed:image];
        
        //初始化一个UIVisualEffect对象
        //我们的模糊效果是加载到backimage这个imageview上面的
        UIVisualEffectView *visuleffectview = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight]];
        //首先要设置一下我们visuleffectview这个视图的大小
        //将他设置为backimage一样大
        visuleffectview.frame = self.frame;
        //然后给他设置透明度
        visuleffectview.alpha = 0.8;
        //加载模糊效果
        [self addSubview:visuleffectview];

        
    }


    return self;
}

@end
